TSGetContingencyResults Sample Code

 

Sample code (VB):

Set mySimAuto = New pwrworld.SimulatorAuto

Output = mySimAuto.OpenCase("G:\wscc_9busCacheTest.pwb")

If Output(0) <> "" Then

DisplayErrorMessage Output(0)

End If

 

Dim objFieldList As Variant

objFieldList = Array("Plot 'Gen_Rotor Angle'", "Bus 4 | frequency")

Output = mySimAuto.TSGetContingencyResults("ctgname1", objFieldList, "0.0", "10.0")

If Output(0) <> "" Then

DisplayErrorMessage Output(0)

End If

Set SimAuto = Nothing

 

 

Sample code (Matlab):

%Initialize SimAuto object

SimAuto = actxserver('pwrworld.SimulatorAuto');

%Initialize SimAutoOutput which is used to store the output of every method call

clear SimAutoOutput;

SimAutoOutput = {''};

%Open the case

SimAutoOutput = SimAuto.OpenCase('G:\wscc_9busCacheTest.pwb');

if ~(strcmp(SimAutoOutput{1},''))

disp(SimAutoOutput{1})

else

disp('OpenCase successful')

end

%%

% Here we get the results for all of the angles directly into Matlab via SimAuto

%%

newCtgName = 'ctgName';

objFieldList = {'"Plot ''Gen_Rotor Angle''"' };

SimAutoOutput = SimAuto.TSGetContingencyResults(newCtgName, objFieldList , '0.0', '10.0');

if ~(strcmp(SimAutoOutput{1},''))

disp(SimAutoOutput{1})

else

disp('GetTSResultsInSimAuto successful')

 

%Get the results

localResults = SimAutoOutput{3};

 

%Get the header variables to use for plot labels

Header = SimAutoOutput{2};

 

% Convert a matrix of strings into a matrix of numbers and plot them

localResultsMat = str2double(localResults);

plot(localResultsMat(:,1), localResultsMat(:,[2:size(localResultsMat,2)]));

title(['Transient stability results for ', newCtgName]);

TimeSeriesNames = Header([4:size(Header,1)],2);

legend(TimeSeriesNames); % these labels come from the HEADER

xlabel('time')

ylabel('Generator rotor angle (degrees)');

end

%Delete (close) the COM object.

delete(SimAuto);